<template>
  <div class="page-container">
    <ex_super_table_page v-bind="option" ref="SuperTablePage">
    </ex_super_table_page>
  </div>
</template>

<script>
import superTablePageFunction from '@/mixin/super-table-page-function';
import emitOnFunction from '@/mixin/emit-on-function';
let emitKey = 'overseas=>wms_count_order_manage'
export default {
  name: "wms_count_order_manage",
  title: "title_count_manage",
  mixins: [superTablePageFunction, emitOnFunction(emitKey)],
  data() {
    return {

      option: {
        search: {

          model: [

            { label: "label_stocktaking_order_code", key: "orderNo", type: 'input', },
            {
              label: "label_status", key: "status", type: 'select',
              enum: 'CountOrderStatusEnum',
            },
            {
              label: "label_fms_service_code_type", key: "type", type: 'select',
              enum: 'CountOrderTypeEnum',
            },
            {
              label: "label_stocktaking_way", key: "mode", type: 'select',
              enum: 'CountOrderModeEnum',
            },
            { label: "label_create_user", key: "creator", type: 'input', },
            {
              label: "label_start_time",
              key: "createDateStart",
              fold: true,
              type: 'date-picker',
              attrs: { type: "datetime" },
            },
            {
              label: "label_end_time",
              key: "createDateEnd",
              fold: true,
              type: 'date-picker',
              attrs: { type: "datetime" },
            },

          ],
        },
        actionExtra: [
          { label: 'label_new', attrs: { type: "primary" }, auth: 'wms_count_order_manage_edit', click: this.clickAdd },

        ],
        action: [

        ],

        table: {
          url: "/wms-api/inside/CountOrderRpc/selectPage.json",
          attrs: {},
          model: [
            { key: 'orderNo', label: 'label_stocktaking_order_code', 'min-width': 150, },
            { key: 'bizType', label: 'label_business_type', 'width': 120, formatter: (r, c, v) => this.$enumShow(v, "BizTypeEnum") },

            { key: 'status', label: 'label_status', 'width': 140, formatter: (r, c, v, i) => this.$enumShow(v, "CountOrderStatusEnum"), },
            { key: 'type', label: 'label_stocktaking_type', 'width': 120, formatter: (r, c, v, i) => this.$enumShow(v, "CountOrderTypeEnum"), },
            { key: 'mode', label: 'label_stocktaking_way', 'width': 120, formatter: (r, c, v, i) => this.$enumShow(v, "CountOrderModeEnum"), },
            { key: 'isBlind', label: 'label_blind_check', 'width': 120, formatter: (r, c, v, i) => this.$enumShow(v, "YesOrNoEnum"), },

            { key: 'isDiff', label: 'label_is_diff', 'width': 100, formatter: (r, c, v, i) => this.$enumShow(v, "YesOrNoEnum"), },
            { key: 'diffNum', label: 'label_diff_count', 'width': 100, },

            { key: 'totalLocationNum', label: 'label_warehouse_location_count', 'width': 100, },
            { key: 'totalSkuCategoryNum', label: 'label_sku_count_sum', 'width': 100, },
            { key: 'creator', label: 'label_create_user', 'width': 120, },
            { key: 'gmtCreate', label: 'label_create_time', 'width': 130, 'show-overflow-tooltip': true, formatter: (r, c, v, i) => this.$dateFormat(v) },
            {
              type: 'operate', width: 210, fixed: "right", operate: [

                { label: 'label_view_detail', click: (row) => this.clickDetail(row) },
                {
                  type: 'more',
                  items: [
                    {
                      label: 'label_stocktaking_operate', auth: 'wms_count_order_manage_operate',
                      disabled: (row) => row.status == 'COMPLETE' || row.status == 'WAIT_REVIEW' || row.status == 'CANCELLED' || row.status == 'REPEAT_COMPLETE',
                      click: (row) => this.clickOperate(row)
                    },
                    {
                      label: 'label_inventory_confirm', auth: 'wms_count_order_manage_operate',
                      disabled: (row) => row.status == 'COMPLETE' || row.status == 'WAIT_REVIEW' || row.status == 'CANCELLED' || row.status == 'REPEAT_COMPLETE',
                      click: (row) => this.completeResult(row)
                    }
                  ]
                },
                {
                  label: 'label_cancel', auth: 'wms_count_order_manage_cancel', type: "confirm-button", url: '/wms-api/inside/CountOrderRpc/cancel.json', message: '确定要取消该盘点单？',
                  buttonClass: "button_text_danger", confirmButtonType: 'danger',
                  disabled: (row) => row.status !== 'WAIT_COUNT',
                  params: (row) => { return { "id": row["id"] } }, done: ['reload', 'tip']
                },
              ]
            },
          ],

        },

      },
    };
  },
  methods: {
    clickOperate(row) {
      this.$router.push({ path: '/page/wms/inside/count_operate', query: { id: row.id, emitKey } })
    },
    clickAdd() {
      this.$router.push({ path: '/page/wms/inside/count_create', query: { emitKey } })
    },
    clickDetail(row) {
      this.$router.push({ path: '/page/wms/inside/count_detail', query: { id: row.id, emitKey } })
    },
    completeResult(row) {
      this.$confirm(this.$tt('label_inventory_confirm'), this.$tt('label_tip'), {
        confirmButtonText: this.$tt('label_confirm'),
        cancelButtonText: this.$tt('label_cancel'),
        type: 'warning'
      }).then(() => {
        this.$ajax({
          url: "/wms-api/inside/CountOrderRpc/finishCountTask.json",
          method: 'post',
          data: { orderId: row.id },
          success: (res) => {
            this.$message.success(this.$tt('tip_submit_success'))
            this.reload()
          },
        })
      }).catch(() => {

      });


    }
  }
}
</script>

<style scoped></style>
